# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer:
pkgname=polyml
pkgver=5.9
pkgrel=0
pkgdesc="ML97 compatible Standard ML implementation"
url="https://www.polyml.org/"
arch="all !aarch64 !ppc64le !s390x !riscv64"
license="LGPL-2.1-only"
makedepends="gmp-dev libffi-dev"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/polyml/polyml/archive/v$pkgver.tar.gz
	"

# FIXME: https://github.com/polyml/polyml/issues/110
case "$CARCH" in
	armhf|armv7) options="!check" ;;
esac

build() {
	# Compiling poly as a dynamically linked position independent
	# executable causes it to segfault. Since Alpine's GCC enables
	# PIE by default we need to explicitly disable it.
	CFLAGS="$CFLAGS -no-pie" ./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--with-system-libffi \
		--with-gmp
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
e996cbe820216e854a50ba214f2a2a0291ee3279eb35be4126b6558bc1582732a236156fb8d0f548b31fca4a496db62ece83d902b6f5e72de64507fdef602e45  polyml-5.9.tar.gz
"
